<!-- extends表明此页面继承自 base.html 文件 -->
{% extends "base.html" %}
{% load staticfiles %}

<!-- 写入 base.html 中定义的 title -->
{% block title %}
    首页
{% endblock title %}

<!-- 写入 base.html 中定义的 content -->
{% block content %}

<!-- 定义放置文章标题的div容器 -->
<div class="container">
    <div class="row mt-2">
    <h2>搜索结果为：</h2>
    <table class="table">
        <thead>
            <tr>
                <th>序号</th>
                <th>岗名</th>
                {% comment %} <th>修改</th> {% endcomment %}
                <th>操作人</th>
                <th>时间</th>
                <th>TBL文件下载</th>
            </tr>
        </thead>        
        <tbody>
        {% for post in post_list %}
            <tr>
                <td>{{ post.id }}</td>
                <td>{{ post.title }}</td>
                <td>{{ post.author }}</td>
                {% comment %} <td>{{ article.body }}</td> {% endcomment %}
                <td>{{ post.created }}</td>
                <td><a href={{post.tbl.url}}>{{post.tbl.name}}</a></td>
                <!-- 需要把post.id传入 -->
                <td><a href="{% url 'article:article_detail' post.id %}" class="btn btn-primary">点击查看</a></td>
            </tr>
        {% endfor %}
        </tbody>
    </table>


{% comment %} 翻页 {% endcomment %}
<nav aria-label="Page navigation">
  <ul class="pagination">

    {% if articles.has_previous %}
        <li><a href="?page={{ articles.previous_page_number }}" aria-label="Previous"><span aria-hidden="true">上一页</span></a></li>
    {% else %}
            <li class="disabled"><a href="" aria-label="Previous"><span aria-hidden="true">上一页</span></a></li>
    {% endif %}    
{#  disabled是当你的按钮不满足的时候不可以点击了#}
    {% if articles.has_next %}
        <li><a href="?page={{ articles.next_page_number }}" aria-label="Next"><span aria-hidden="true">下一页</span></a></li>
    {% else %}
            <li class="disabled"><a href="" aria-label="Next"><span aria-hidden="true">下一页</span></a></li>
    {% endif %} 

    {% for i in pageRange %}
         {% if current_num == i %}
          <li class="active"><a href="?page={{ i }}">{{ i }}</a></li>

         {% else %}
          <li><a href="?page={{ i }}">{{ i }}</a></li>
         {% endif %}
    {% endfor %}

 
  </ul>
</nav>


    </div>
</div>
{% endblock content %}